
package cn.edu.scau.cmi.hombio.service;

import cn.edu.scau.cmi.hombio.domain.Employee;
import cn.edu.scau.cmi.hombio.domain.Role;
import cn.edu.scau.cmi.hombio.domain.RoleEmployee;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/pigRs-security-context.xml",
		"file:./resources/pigRs-service-context.xml",
		"file:./resources/pigRs-dao-context.xml",
		"file:./resources/pigRs-web-context.xml" })
@Transactional
public class RoleEmployeeServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected RoleEmployeeService service;

	/**
	 * Instantiates a new RoleEmployeeServiceTest.
	 *
	 */
	public RoleEmployeeServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	* Delete an existing Employee entity
	* 
	 */
	@Test
	public void deleteRoleEmployeeEmployee() {
		// TODO: JUnit - Populate test inputs for operation: deleteRoleEmployeeEmployee 
		Integer roleemployee_id = 0;
		Integer related_employee_id = 0;
		RoleEmployee response = null;
		response = service.deleteRoleEmployeeEmployee(roleemployee_id, related_employee_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteRoleEmployeeEmployee
	}

	/**
	 * Operation Unit Test
	* Save an existing Role entity
	* 
	 */
	@Test
	public void saveRoleEmployeeRole() {
		// TODO: JUnit - Populate test inputs for operation: saveRoleEmployeeRole 
		Integer id = 0;
		Role related_role = new cn.edu.scau.cmi.hombio.domain.Role();
		RoleEmployee response = null;
		response = service.saveRoleEmployeeRole(id, related_role);
		// TODO: JUnit - Add assertions to test outputs of operation: saveRoleEmployeeRole
	}

	/**
	 * Operation Unit Test
	* Load an existing RoleEmployee entity
	* 
	 */
	@Test
	public void loadRoleEmployees() {
		Set<RoleEmployee> response = null;
		response = service.loadRoleEmployees();
		// TODO: JUnit - Add assertions to test outputs of operation: loadRoleEmployees
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findRoleEmployeeByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findRoleEmployeeByPrimaryKey 
		Integer id_1 = 0;
		RoleEmployee response = null;
		response = service.findRoleEmployeeByPrimaryKey(id_1);
		// TODO: JUnit - Add assertions to test outputs of operation: findRoleEmployeeByPrimaryKey
	}

	/**
	 * Operation Unit Test
	* Delete an existing Role entity
	* 
	 */
	@Test
	public void deleteRoleEmployeeRole() {
		// TODO: JUnit - Populate test inputs for operation: deleteRoleEmployeeRole 
		Integer roleemployee_id_1 = 0;
		Integer related_role_id = 0;
		RoleEmployee response = null;
		response = service.deleteRoleEmployeeRole(roleemployee_id_1, related_role_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteRoleEmployeeRole
	}

	/**
	 * Operation Unit Test
	* Save an existing RoleEmployee entity
	* 
	 */
	@Test
	public void saveRoleEmployee() {
		// TODO: JUnit - Populate test inputs for operation: saveRoleEmployee 
		RoleEmployee roleemployee = new cn.edu.scau.cmi.hombio.domain.RoleEmployee();
		service.saveRoleEmployee(roleemployee);
	}

	/**
	 * Operation Unit Test
	* Delete an existing RoleEmployee entity
	* 
	 */
	@Test
	public void deleteRoleEmployee() {
		// TODO: JUnit - Populate test inputs for operation: deleteRoleEmployee 
		RoleEmployee roleemployee_1 = new cn.edu.scau.cmi.hombio.domain.RoleEmployee();
		service.deleteRoleEmployee(roleemployee_1);
	}

	/**
	 * Operation Unit Test
	* Return a count of all RoleEmployee entity
	* 
	 */
	@Test
	public void countRoleEmployees() {
		Integer response = null;
		response = service.countRoleEmployees();
		// TODO: JUnit - Add assertions to test outputs of operation: countRoleEmployees
	}

	/**
	 * Operation Unit Test
	* Save an existing Employee entity
	* 
	 */
	@Test
	public void saveRoleEmployeeEmployee() {
		// TODO: JUnit - Populate test inputs for operation: saveRoleEmployeeEmployee 
		Integer id_2 = 0;
		Employee related_employee = new cn.edu.scau.cmi.hombio.domain.Employee();
		RoleEmployee response = null;
		response = service.saveRoleEmployeeEmployee(id_2, related_employee);
		// TODO: JUnit - Add assertions to test outputs of operation: saveRoleEmployeeEmployee
	}

	/**
	 * Operation Unit Test
	* Return all RoleEmployee entity
	* 
	 */
	@Test
	public void findAllRoleEmployees() {
		// TODO: JUnit - Populate test inputs for operation: findAllRoleEmployees 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<RoleEmployee> response = null;
		response = service.findAllRoleEmployees(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllRoleEmployees
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
